let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgs: [{
      id: 1
    }, {
      id: 2
    }, {
      id: 3
    }, {
      id: 4
    }, {
      id: 5
    }],
    starId:0,
    src1: '/images/star-yellow.png',
    src2: '/images/star-gray.png',
    content:"",
    id:0,
    status:0
  },

  //查询评价内容
  scoreDetailApi(){
    var id = this.data.id;
    var params = {
      id:id,
    };
    var self = this;
      app.request('post', '/api/Help/scoreDetailApi', params).then(res => {
        if(res.data.code==0){
          var detail = res.data.detail;
          self.setData({status:detail.status,starId:detail.score,content:detail.score_contetn});
        }
      }).catch(err => console.log(err));
  },

  //内容填充
  inputArea:function(e){
    this.setData({content:e.detail.value});
  },

  //提交操作
  backdrop_btn:function(){
      var id = this.data.id;
      var score = this.data.starId;
      var content = this.data.content;
     
      var params = {
        appid: app.globalData.appid,
        content:content,
        id:id,
        score:score
      };

      var self = this;
      app.request('post', '/api/Help/scoreApi', params).then(res => {
        if(res.data.code==0){
          wx.showToast({
            title: '提交成功',
            icon: 'none',
            duration: 1500,
            success:function(){
              self.setData({content:'',show:false});
              wx.navigateBack();
            },
          });
        }
      }).catch(err => console.log(err));

  },

  select(e) {
    this.data.starId = e.currentTarget.dataset.index;
    this.setData({
      starId: this.data.starId
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.id!='undefined'){
      this.setData({id:options.id});
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
      this.scoreDetailApi()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})